package com.crazy.common.date;
import java.beans.PropertyEditor;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.support.WebBindingInitializer;
import org.springframework.web.context.request.WebRequest;
/**
 * Spring3之前的 PropertyEditor<br>
 * 使用WebBindingInitializer批量注册 PropertyEditor 如果想在多个控制器同时注册多个相同的PropertyEditor
 * 时，可以考虑使用 WebBindingInitializer。
 * @author Zhang Weiwei
 * @datetime 2013-8-18上午11:54:45
 */
public class MyWebBindingInitializer implements WebBindingInitializer {
	@Override
	public void initBinder(WebDataBinder binder, WebRequest req) {
		DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		PropertyEditor propertyEditor = new CustomDateEditor(dateFormat, true);
		binder.registerCustomEditor(Date.class, propertyEditor);
	}
}
